package graphics.objects;
import org.lwjgl.opengl.GL11;

import graphics.system.Color;
import graphics.system.GLTools;
import tools.Point;
public class GLine extends GShape {
	public Point p0;
	public Point p1;
	private float width;
	public GLine(Point p0, Point p1, float width, Color color) {
		super(p0.add(p1).mul(0.5f), 0, color);
		node.boundingrad = p0.distance(p1) * 0.5f;
		this.width = width;
		this.p0 = p0;
		this.p1 = p1;
	}
	public void draw() {
		if (width <= 0)
			return;
		Point dxn = p0.sub(p1).normal().normalize().mul(width * 0.5f);
		Point a = p0.add(dxn);
		Point b = p0.add(dxn.mul(-1));
		Point c = p1.add(dxn.mul(-1));
		Point d = p1.add(dxn);
		GLTools.drawQuad(a, b, c, d, color);
	}
	public void drawGlow() {
		if (!this.hasGlow || width <= 0)
			return;
		Point dxn = p0.sub(p1).normal().normalize().mul(width * 0.5f + this.glowscale);
		Point a = p0.add(dxn);
		Point b = p0.add(dxn.mul(-1));
		Point c = p1.add(dxn.mul(-1));
		Point d = p1.add(dxn);
		GLTools.drawQuad(a, b, c, d, color);
	}
	public void drawShadow() {
		if (!this.hasShadow || width <= 0)
			return;
		Point dxn = p0.sub(p1).normal().normalize().mul(width * 0.5f);
		Point a = p0.add(dxn);
		Point b = p0.add(dxn.mul(-1));
		Point c = p1.add(dxn.mul(-1));
		Point d = p1.add(dxn);
		GLTools.drawQuad(a, b, c, d, Color.black);
	}
	public void drawDebug() {
		Point dxn = p0.sub(p1).normal().normalize().mul(width * 0.5f);
		Point a = p0.add(dxn);
		Point b = p0.add(dxn.mul(-1));
		Point c = p1.add(dxn.mul(-1));
		Point d = p1.add(dxn);
		GLTools.drawQuad(a, b, c, d, color.withAlpha(0.5f));
		GLTools.drawCircle(p0, 4, 0, Color.green, false);
		GLTools.drawCircle(p1, 4, 0, Color.red, false);
	}
}
